package com.mxpio.erp.equipment.service.impl;

import com.mxpio.erp.common.equipment.entity.EquipmentPersonGroupDetail;
import com.mxpioframework.jpa.JpaUtil;
import org.springframework.stereotype.Service;

import com.mxpio.erp.common.equipment.entity.EquipmentPersonGroup;
import com.mxpio.erp.common.equipment.service.EquipmentPersonGroupService;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 人员群组管理Service业务层处理
 *
 * @author Cheng
 * @date 2023-06-28
 */
@Service
public class EquipmentPersonGroupServiceImpl extends BaseServiceImpl<EquipmentPersonGroup> implements EquipmentPersonGroupService {

    @Override
    @Transactional(readOnly = true)
    public List<String> selectByUsername(String username) {
        List<EquipmentPersonGroupDetail> groupDetails = JpaUtil.linq(EquipmentPersonGroupDetail.class).equal("userId", username).list();
        List<String> list = groupDetails.stream().map(item -> item.getGroupId()).collect(Collectors.toList());
        return list;
    }
}
